package com.zb.zeus.common.engine.config;

import com.zb.zeus.common.engine.Calculator;
import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;

import java.math.BigDecimal;

/**
 * @author fujianjian
 * @since 2021/4/7 11:13
 */
@Data
@RefreshScope
@Configuration
@ConfigurationProperties(prefix = CalcConfig.CONFIG_PREFIX)
public class CalcConfig implements InitializingBean {
    protected final static String CONFIG_PREFIX = "zeus.engine.calc";

    private boolean forceCalc;

    private String scriptDir;

    private String scriptName;

    private String methodName;

    private BigDecimal incrFactor;

    private BigDecimal plusThreshold;


    @Override
    public void afterPropertiesSet() throws Exception {
        Calculator.setConfig(this);
    }
}
